﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Pan
{
    public partial class share : System.Web.UI.Page
    {
        protected void Page_PreInit(object sender, EventArgs e)
        {
            Master.needLogin = true;
            Master.side = 2;
        }

        protected void doPost_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["PanConnectionString"].ToString();
            try
            {
                conn.Open();
                if (IsPostBack)
                {
                    if (Code.Text.Length > 0)
                    {
                        string[] dellist = Code.Text.Trim().Split(',');
                        int count = 0;
                        foreach (string s in dellist)
                        {
                            SqlCommand cmd = new SqlCommand();
                            cmd.Connection = conn;
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "DelShare";
                            cmd.Parameters.Add("@uid", SqlDbType.Int).Value = Master.uid;
                            cmd.Parameters.Add("@code", SqlDbType.VarChar, 255).Value = s;
                            count += cmd.ExecuteNonQuery();
                        }
                        if (count > 0)
                        {
                            Response.Redirect("/share.aspx");
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Master.RespLabel.Text = "<script>layui.use('layer',function(){layui.layer.alert('" + err.Message + "')})</script>";
            }
            finally
            {
                conn.Close();
            }
            Code.Text = "";
        }
    }
}